var AjaxUtil = {
    ajaxGet: function (url, params, callback) {
        $.ajax
        ({
            type: "get",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            data: params,
            url: url,
            success: function (data) {
                callback(data);
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                callback({
                    "success": false,
                    "message": XMLHttpRequest.status + ' ' + XMLHttpRequest.responseText
                });
            }
        });
    },
    ajaxGetSync: function (url, params) {
        var result = null;

        $.ajax
        ({
            type: "get",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            data: params,
            url: url,
            async: false,
            success: function (data) {
                result = data;
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                result = {
                    "success": false,
                    "message": XMLHttpRequest.status + ' ' + XMLHttpRequest.responseText
                };
            }
        });

        return result;
    },
    ajaxPost: function (url, postData, callback) {
        $.ajax
        ({
            type: "post",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            data: postData,
            url: url,
            success: function (data) {
                callback(data);
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                callback({
                    "success": false,
                    "message": XMLHttpRequest.status + ' ' + XMLHttpRequest.responseText
                });
            }
        });
    },
    ajaxPostSync: function (url, postData) {
        var result = null;

        $.ajax
        ({
            type: "post",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            url: url,
            data: postData,
            async: false,
            success: function (data) {
                result = data;
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                result = {
                    "success": false,
                    "message": XMLHttpRequest.status + ' ' + XMLHttpRequest.responseText
                };
            }
        });

        return result;
    },
    ajaxPut: function (url, putData, callback) {
        $.ajax
        ({
            type: "put",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            data: putData,
            url: url,
            success: function (data) {
                callback(data);
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                callback({
                    "success": false,
                    "message": XMLHttpRequest.status + ' ' + XMLHttpRequest.responseText
                });
            }
        });
    },
    ajaxPutSync: function (url, putData) {
        var result = null;

        $.ajax
        ({
            type: "put",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            url: url,
            data: putData,
            async: false,
            success: function (data) {
                result = data;
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                result = {
                    "success": false,
                    "message": XMLHttpRequest.status + ' ' + XMLHttpRequest.responseText
                };
            }
        });

        return result;
    },
    ajaxDelete: function (url, delData, callback) {
        $.ajax
        ({
            type: "delete",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            data: delData,
            url: url,
            success: function (data) {
                callback(data);
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                callback({
                    "success": false,
                    "message": XMLHttpRequest.status + ' ' + XMLHttpRequest.responseText
                });
            }
        });
    },
    ajaxDeleteSync: function (url, delData) {
        var result = null;

        $.ajax
        ({
            type: "delete",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            url: url,
            data: delData,
            async: false,
            success: function (data) {
                result = data;
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                result = {
                    "success": false,
                    "message": XMLHttpRequest.status + ' ' + XMLHttpRequest.responseText
                };
            }
        });

        return result;
    }
};
